package store.model;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 针对表cart的实体类
 */
public class Cart {
    private Integer cartId;
    private Integer goodsNO;
    private Integer num;
    private Integer accountId;
    private Date createTime;

    public Cart() {}

    public static class CartRecover implements Recover<Cart> {

        @Override
        public List<Cart> recover(ResultSet set) throws SQLException {
            List<Cart> carts = new ArrayList<>();
            while (set.next()) {
                carts.add(new Cart(set.getInt("cart_id"),
                        set.getInt("goods_no"),
                        set.getInt("num"),
                        set.getInt("account_id"),
                        set.getDate("create_time")));
            }
            return carts;
        }
    }

    public Cart(Integer cartId, Integer goodsNO, Integer num, Integer accountId, Date createTime) {
        this.cartId = cartId;
        this.goodsNO = goodsNO;
        this.num = num;
        this.accountId = accountId;
        this.createTime = createTime;
    }

    public Integer getCartId() {
        return cartId;
    }

    public void setCartId(Integer cartId) {
        this.cartId = cartId;
    }

    public Integer getGoodsNO() {
        return goodsNO;
    }

    public void setGoodsNO(Integer goodsNO) {
        this.goodsNO = goodsNO;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public Integer getAccountId() {
        return accountId;
    }

    public void setAccountId(Integer accountId) {
        this.accountId = accountId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
